<html><!-- InstanceBegin template="/Templates/_Admin_Template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>TCedit 测试用例编写工具 - 选择产品和版本</title>
<!-- InstanceEndEditable -->
<link rel="shortcut icon" href="favicon.ico">
<link href="/css/common.css" rel="stylesheet" type="text/css">
<script src="/js/common.js"></script>
<script src="/js/jquery/jquery.js"></script>
<script language="JavaScript">
var products=new Array();
var versions=new Array();

#foreach($a in $products)
  #set($i=$velocityCount)
  products[$i - 1]=["$!{a.id}", "$!{a.name}"];
  versions[$i - 1]=new Array();
  #foreach($b in $a.versions)
    versions[$i - 1][$velocityCount - 1]=["$!{b.id}", "$!{b.name}"];
  #end
#end

$(document).ready(function (){
  for(var i=0;i<products.length;i++) {
    $("#product").append("<option value='" + products[i][0] + "'>" + products[i][1] + "</option>");
  }
  $('#product').attr('value','$!{currentProductID}');
  productSelectChange();
  $('#version').attr('value','$!{currentVersionID}');
});

function productSelectChange() {
  document.getElementById("version").options.length=0;
  var tmp=versions[$("#product").get(0).selectedIndex];
  if (typeof tmp != "undefined") {
    for (var j=0;j<tmp.length;j++) {
      $("#version").append("<option value='" + tmp[j][0] + "'>" + tmp[j][1] + "</option>"); 
    }
  }
}

function selectedItem(selectName, itemValue) {
  var objSelect=document.getElementById(selectName);
  for (var i=0; i < objSelect.options.length; i++) {
    if (objSelect.options[i].text.indexOf(itemValue) != -1) {
      objSelect.options[i].selected=true;
      if (selectName=="product") {
        productSelectChange();
      }
      break;
    }
  }
}

function clickSubmit() {
  document.formData.productID.value=document.getElementById("product").value;
  document.formData.versionID.value=document.getElementById("version").value;
}
</script>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->

<!-- InstanceBeginEditable name="MainContent" -->
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="100%" height="100%" valign="center" align="center" valign="top">
      <table width="70%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td colspan="4" bgcolor="#dedeef"><b>选择产品和版本</b></td>
        </tr>
        <tr>
          <td colspan="3">
            #if($error)
              <font color="#FF0000">$error</font>
            #end
          </td>
        </tr>
        <form action="/selectProductVersion.jspx?url=${url}" method="post" enctype="multipart/form-data" name="formData" id="formData">
        <tr>
          <td width="47%"></td>
          <td width="6%">&nbsp;</td>
          <td width="47%"></td>
        </tr>
        <tr>
          <td>产品：<input type="text" class="text" onKeyUp="selectedItem('product', this.value)" /></td>
          <td></td>
          <td>版本：<input type="text" class="text" onKeyUp="selectedItem('version', this.value)" /></td>
        </tr>
        <tr>
          <td><select size="21" style="width:330px; height:350px;" name="product" id="product" onChange="productSelectChange()"></td>
          <td></td>
          <td><select size="21" style="width:330px; height:350px;" name="version" id="version"></select></td>
        </tr>
        <tr>
          <td><BR></td>
          <td></td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td align="right">
            <input name="productID" id="productID" type="hidden" value="" />
            <input name="versionID" id="versionID" type="hidden" value="" />
            <input name="Submit" type="submit" class="button" id="Submit" value="确定" onClick="clickSubmit()"/>
            <input type="submit" class="button" value="返回" onClick="javascript:window.history.back()" />
          </td>
          <td></td>
        </tr>
        </form>
      </table>
    </td>
  </tr>
</table>
<!-- InstanceEndEditable -->
</body>
<!-- InstanceEnd --></html>